 <?php echo $this->Html->script(array('ckeditor/ckeditor')); ?>
          <?php echo $this->Form->create("Banner",array('type' => 'file'));
                echo $this->Form->hidden('id');

           ?>
          
             <fieldset>
              <div class="input-content">
                  <div class="input ">
                    <label for="last-name">Tên banner(<span>*</span>)</label>
                    <?php echo $this-> Form->input('banner_name',array('class'=>'placeholder','placeholder'=>' Tên banner','label'=>false,'div'=>false));?>
                    <div class="error-message" id="error_name"></div>
				
		          </div>
                  <div class="input">
                    <label for="last-name">File path(<span>*</span>)</label>
                    <?php
                    echo $this->Form->input('file_name', array(
                                      'type' => 'file',
                                      
                                      'label'=>false,
                                      'div'=>false,
									  'onChange'=>'return readURL(this)'
                                      
                                      
                                      
                                  )
                    ); ?>
					<div class="error-message" id="error_file"></div>
					<div style="clear:both;margin-left: 146px;padding-top: 10px;">
					<img id="image_show" src="<?php echo ( isset($this->request->data['Banner']['full_path']))?$this->request->data['Banner']['full_path']:"#"; ?>" alt="" width="200" height="150" />
					</div>
				   </div>
                   
                  
                  <div class="submit">
                   <?php echo $this->Form->submit("",array('class'=>'save','id'=>'btnSave')); ?>
                   <!-- <input type="submit" id="btnSave" value="" class="save"> -->
                    <a href="javascript:resetForm()" id="resetForm" class="reset">Reset</a>
                  </div>
            </fieldset>
          <?php echo $this->Form->end(); ?>
    <script>
	function readURL(input) {
            if (input.files && input.files[0]) {
                var reader = new FileReader();

                reader.onload = function (e) {
                    $('#image_show')
                        .attr('src', e.target.result)
                        .width(200)
                    .height(200);
                };

              reader.readAsDataURL(input.files[0]);
            }
     }
    $("#btnSave").click(function(){
            var  validateBannerName   = new validate("BannerBannerName","error_name","Bạn chưa nhập tên banner");
            var  validateFile       = new validate("BannerFileName",'error_file',"Bạn chưa chọn file ảnh");
            var  result     = validateBannerName.notEmpty();
            var  result2    = validateFile.notEmpty();
             if(!(result && result2))
            {
                $('html, body').animate({ scrollTop: 0 }, 'slow');
            }
            return result && result2;
        });
     function resetForm()
     {
        window.location.reload();
     }
    </script>